﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 玩家基类
/// </summary>
public class BasePlayer : MonoBehaviour {

	#region 玩家基础数值

	[Header("基础数值")]
	[Tooltip("玩家血量"),SerializeField]
	private int _hp;

	protected bool isDying=false;

    public int HP
    {
        protected set
        {
            if (value > 0)
            {
                _hp = value;
                return;
            }
            if(!isDying)
            {
                isDying=true;
                Dead();
            }
        }

        get
        {
            return _hp;
        }
    }

	

	#endregion
	
	#region 基础函数
	protected virtual void Dead()
	{
	}
	public virtual void GetDamage(int value)
	{
		HP-=value;
	}

	public virtual void Recover(int value)
	{
		HP+=value;
	}
	#endregion
	
}
